package pl.javarsovia.javarsovia4android.activities;

import java.util.List;

import pl.javarsovia.R;
import pl.javarsovia.javarsovia4android.adapters.MySessionAdapter;
import pl.javarsovia.javarsovia4android.domain.ConferenceProvider;
import pl.javarsovia.javarsovia4android.domain.Slot;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.AdapterView.OnItemClickListener;

/**
 * @author mateusz.grzechocinski@gmail.com
 * @since 2010-06-06
 */
public class MySessionActivity extends Activity {

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.my_session);
		List<Slot> slots = ConferenceProvider.getConference().getSlots();
		ListView list = (ListView) findViewById(R.id.my_session_list);
		final MySessionAdapter adapter = new MySessionAdapter(this, slots);
		list.setAdapter(adapter);
		list.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
				MySessionActivity activity = MySessionActivity.this;
				Intent intent = new Intent(activity, LectureDetailsActivity.class);
				intent.putExtra(LectureDetailsActivity.LECTURE, adapter.getLectureFrom(position));
				activity.startActivity(intent);
			}
		});

	}
}
